/**
 * Copyright 2011, Under-Ground Studio.
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package cn.edu.zju.vlis.aus.chart;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import cn.edu.zju.vlis.aus.R;

/**
 * Instance of this class represents an item in the bar chart view. It contains
 * an icon of application ,a name, the usage count and a bar view.
 * 
 * @author ymsong (songyuming1985@gmail.com) 2011-9-17
 */
public class BarChartItemView extends LinearLayout {
	private ImageView iconView;
	private TextView appNameView;
	private BarView barView;

	/**
	 * The constructor.
	 * 
	 * @param context
	 */
	public BarChartItemView(Context context) {
		super(context);
		LayoutInflater inflater = LayoutInflater.from(context);
		View v = inflater.inflate(R.layout.list_item_bar_chart, this);
		iconView = (ImageView) v.findViewById(R.id.image_app_icon_bar);
		appNameView = (TextView) v.findViewById(R.id.text_app_name_bar);
		barView = (BarView) v.findViewById(R.id.bar_view);
	}

	public void setIcon(Drawable icon) {
		iconView.setImageDrawable(icon);
	}

	public void setAppName(String name) {
		appNameView.setText(name);
	}

	public void setCount(int count) {
		this.barView.setCount(count);
	}
	
	public void setPagckageName(String packageName){
		this.barView.setPackageName(packageName);
	}
}
